<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

		<link rel="stylesheet" type="text/css" href="../css/index%20(1).css" />
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vant.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		
		<script src="html5plus://ready"></script>
		<title></title>
		<style type="text/css">
			body {
				background-color: gainsboro;
			}
			
			#one {
				background-color: red;
				height: 50px;
			}
			
			.van-nav-bar__title {
				color: white;
				font-size: 15px;
				padding-top: 5px;
			}
			
			.van-nav-bar .van-icon {
				color: white;
				padding-top: 10px;
			}
			
			.van-nav-bar__text {
				color: white;
				padding-top: 10px;
			}
			
			.van-address-list {
				height: 100%;
				padding-bottom: 10px;
				box-sizing: border-box;
			}
			
			.van-button--small {
				margin-left: -30px;
			}
			
			p {
				font-size: 16px;
			}
			#dl{
			padding-left: 50px;
			padding-right: 50px;
			margin-bottom: 20px;
		}
		</style>
	</head>

	<body>
		<div id="app">
			<van-row>
				<van-nav-bar title="注册账号" left-text="返回" right-text="确认" left-arrow id="one" @click-left="back"></van-nav-bar>
				
			</van-row>

			<van-row id="two">
				<van-cell-group>
					<van-field v-model="phone" label="手机号" placeholder="请输入手机号" id="z1"></van-field>

					<van-field v-model="sms" center clearable label="短信验证码" placeholder="请输入短信验证码" id="z2">
					<van-button slot="button" size="small" type="primary" @click="yzm">发送验证码</van-button>
					</van-field>
				</van-cell-group>
				<!--密码-->
				<van-cell-group>

					<van-field v-model="password" type="password" placeholder="设置登录密码（至少6位）" id="z3"></van-field>
					<van-field v-model="rpassword" type="password" size="" placeholder="请确密码" id="z4"></van-field>
					<van-field v-model="name"  placeholder="昵称（最多20字）" id="z5"></van-field>
					<van-field v-model="code"  placeholder="县/区Code" id="z6"></van-field>
				</van-cell-group>
				
				
				

			</van-row>
			<p>注册会员及表示同意<a href="#">《第九组用户注册协议》</a></p>
			<van-col span="24" id="dl">
				 	<van-button size="large" square type="danger" @click="zcdl">立即登录</van-button>
			</van-col>
		</div>
		<script type="text/javascript">
		var _this=this;
		var yzm=""
			var app = new Vue({
				el: "#app",
				data: {
					chosenAddressId: "",
					password: "",
					list: [],
					sms: yzm,
					rpassword: "",
					name:"",
					code:"",
					phone: ""
				},
				methods:{
					back:function(){
						//window.location.href="login.html"
						plus.webview.open("login.html","lo");
					},
					zcdl:function(){
						var _this=this;
						if(_this.password!=_this.rpassword){
							app.$toast("密码错误或者不一致");
						}
						else{
						ajax({
							url:"http://dsapi.ysd3g.com/API/UserRegister",
							dataType:"JSONP",
							data:{
								phone:_this.phone,
								code:yzm,
								password:_this.password,
								districtCode:410522,
								nickName:_this.name
							},
							success:function(res){
								var _this=this;
								console.log(res)
								if(_this.password==_this.rpassword){
									app.$toast("用户："+res.UserData.NickName+"注册成功");
									//window.location.href="login.html"
									plus.webview.open("login.html","lo");
								}
								else{
									app.$toast("注册失败");
								}
								
								
							}
							
						});
						}
					},
					yzm:function(){
						var _this=this;
						ajax({
							url:"http://dsapi.ysd3g.com/API/SendRegisterPhoneCode",
							dataType:"JSONP",
							data:{
								phone: _this.phone,
							},	
							success:function(res){
								console.log(res)
								if(res.Error==true){
									app.$toast("手机号码不正确哦！");
								}
								else{
									app.$toast(res.Code);
								}
								
								yzm=res.Code
								console.log(yzm)
								
							}
							
						});
					}
				}

			});
		</script>
	</body>

</html>